package com.lsl.exception;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@ControllerAdvice
public class MyException {
    @ExceptionHandler(value = Exception.class)
    public ModelAndView modelAndView(HttpServletRequest request, HttpServletResponse response,Exception e)throws Exception{
        ModelAndView mv = new ModelAndView();
        mv.addObject("exception", e);
        mv.addObject("url", request.getRequestURL());
        mv.setViewName("error");
        return mv;
    }
}
